﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using TSharp.Core.Mvc;

[assembly: PreApplicationStartMethod(typeof(CollectCotrollerModule), "Start")]
namespace TSharp.Core.Mvc
{
    public class CollectCotrollerModule : Disposable, IHttpModule
    {
        public static void Start()
        {
            if (Env.TSharpGlobal.IsDebuggerEnable)
                DynamicModuleUtility.RegisterModule(typeof(CollectCotrollerModule));
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += context_BeginRequest;

        }

        private void context_BeginRequest(object sender, EventArgs e)
        {
            CollectControllerManage.ProcessActionsIntoDatabase();
        }

        private bool disposed;
        protected override void Dispose(bool disposing)
        {
            if (!disposed)
            {
                try
                {
                    if (disposing)
                    {
                        // 释放托管资源
                    }
                    // 这里释放所有非托管资源
                    disposed = true;
                }
                finally
                {
                    base.Dispose(disposing);
                }
            }
        }
    }
}
